package cn.tedu.mall.front.controller;

import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.front.service.IFrontCategoryService;
import cn.tedu.mall.pojo.front.entity.FrontCategoryEntity;
import cn.tedu.mall.pojo.front.vo.FrontCategoryTreeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/front/category")
public class FrontCategoryController {

    private final IFrontCategoryService frontCategoryService;

    @Autowired
    public FrontCategoryController(IFrontCategoryService categoryService) {
        this.frontCategoryService = categoryService;
    }

    @GetMapping("/all")
    public JsonResult<FrontCategoryTreeVO<FrontCategoryEntity>> categoryTree() {
        FrontCategoryTreeVO<FrontCategoryEntity> frontCategoryTreeVO = frontCategoryService.categoryTree();
        return JsonResult.ok(frontCategoryTreeVO);
    }

}
